package com.hqyj.dao.dao;

import com.hqyj.pojo.MakeApply;
import com.hqyj.pojo.customerInfo;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface TableDao {
    //用户端申请时插入数据库
    @Insert("insert into applyTable (customerName,serviceType,serviceDate,Note,email,address) values (#{customerName},#{serviceType},#{serviceDate},#{Note}, #{email}, #{address}) ")
    int insertApply(MakeApply makeApply);

    //用户请求卡片上的数据回显
    @Select("SELECT * FROM applytable")
    List<MakeApply> findFromApplyTable();

    //点击处理后，通过用户名来查询
    @Select("SELECT *  FROM applytable WHERE customerName =#{userName}")
    List<MakeApply> findByName(String userName);

    //点击处理后，通过用户名来查询Id
    @Select("SELECT Id  FROM applytable WHERE customerName =#{userName}")
    List<MakeApply> findId(String customerName);

    //点击处理后，通过用户名和ID来查询
    @Select("SELECT servicedate, Note FROM applytable WHERE Id = #{Id}")
    List<MakeApply> findById(String Id);

    //点击处理后，管理者提交插入附加数据,*********3.17**********
    @Update("UPDATE applytable set selectDate = #{dealCalender},Cost = #{predictCost}, serviceTime =  #{serviceTime}, Dealed = #{Dealed} WHERE Id = #{customerId}")
    int updateApply(String customerId, String userName,String dealCalender, String predictCost, String serviceTime, String Dealed);

    //顾客看到服务记录
    @Select("SELECT serviceType,serviceDate,Dealed  FROM applytable WHERE customerName =#{userName}")
    List<MakeApply> findByNameList(String userName);

    // 查询服务记录
    @Select("SELECT * FROM applytable WHERE Dealed = '已处理'")
    List<MakeApply> findSerList();

    //后台修改数据库，更新数据库
    @Update("UPDATE applytable SET remark = #{remark} where Id = #{Id}")
    int updateRemark(String remark, String Id);

    //后台用户申请卡片，根据用户名获取地址和邮箱
    @Select("SELECT * FROM manager WHERE userName = #{customerName} ")
    List<customerInfo> askAddByName(String customerName);

}
